﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;

using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using PdfSharp.Pdf.Security;
using PdfSharp.Pdf.Advanced;

using CE.Mail;
using CE.Image;
using CE.Global;
using CE.Database;
using CE.User;
using CE.PostCode;
using CE.CarInsurance;
using CE.Provider;
using CE.Security;

/// <summary>
/// Summary description for LMGCarInsurancePDFOutput
/// </summary>
///  
namespace CE.CarInsurance
{
    public class AZCpCarInsurancePDFOutput
    {
        private string _pageTitle;
        public string PageTitle
        {
            get { return _pageTitle; }
            set { _pageTitle = value; }
        }

        private string _proposalNo;
        public string ProposalNo
        {
            get { return _proposalNo; }
            set { _proposalNo = value; }
        }

        private string _revisionNo;
        public string RevisionNo
        {
            get { return _revisionNo; }
            set { _revisionNo = value; }
        }

        private string _quotationNo;
        public string QuotationNo
        {
            get { return _quotationNo; }
            set { _quotationNo = value; }
        }

        private string _producerCode;
        public string ProducerCode
        {
            get { return _producerCode; }
            set { _producerCode = value; }
        }

        private DateTime _Applicationdate;
        public DateTime ApplicationDate
        {
            get { return _Applicationdate; }
            set { _Applicationdate = value; }
        }


        #region Customer Profile
        private string _NRIC;
        public string NRIC
        {
            get { return _NRIC; }
            set { _NRIC = value; }
        }

        private string _customerName;
        public string CustomerName
        {
            get { return _customerName; }
            set { _customerName = value; }
        }

        string _customerAddress;
        public string CustomerAddress
        {
            get { return _customerAddress; }
            set { _customerAddress = value; }
        }

        string _customerUnitNo;
        public string CustomerUnitNo
        {
            get { return _customerUnitNo; }
            set { _customerUnitNo = value; }
        }

        string _customerHomeNo;
        public string CustomerHomeNo
        {
            get { return _customerHomeNo; }
            set { _customerHomeNo = value; }
        }

        string _customerPostCode;
        public string CustomerPostCode
        {
            get { return _customerPostCode; }
            set { _customerPostCode = value; }
        }

        string _officemobileNo;
        public string OfficeMobileNo
        {
            get { return _officemobileNo; }
            set { _officemobileNo = value; }
        }

        string _employersName;
        public string EmployersName
        {
            get { return _employersName; }
            set { _employersName = value; }
        }

        string _emailaddress;
        public string EmailAddress
        {
            get { return _emailaddress; }
            set { _emailaddress = value; }
        }

        string _customerGender;
        public string CustomerGender
        {
            get { return _customerGender; }
            set { _customerGender = value; }
        }

        DateTime _customerDOB;
        public DateTime CustomerDOB
        {
            get { return _customerDOB; }
            set { _customerDOB = value; }
        }

        string _customeroccupation;
        public string CustomerOccupation
        {
            get { return _customeroccupation; }
            set { _customeroccupation = value; }
        }

        string _customerjobnature;
        public string CustomerJobNature
        {
            get { return _customerjobnature; }
            set { _customerjobnature = value; }
        }

        string _customermaritalstatus;
        public string CustomerMaritalStatus
        {
            get { return _customermaritalstatus; }
            set { _customermaritalstatus = value; }
        }

        Int32 _customerdrivingexperience;
        public Int32 CustomerDrivingExperience
        {
            get { return _customerdrivingexperience; }
            set { _customerdrivingexperience = value; }
        }

        #endregion

        #region Addtnal Drivers

        string _driver1Name;
        public string Driver1Name
        {
            get { return _driver1Name; }
            set { _driver1Name = value; }
        }

        string _driver1Gender;
        public string Driver1gender
        {
            get { return _driver1Gender; }
            set { _driver1Gender = value; }
        }

        DateTime _driver1DOB;
        public DateTime Driver1DOB
        {
            get { return _driver1DOB; }
            set { _driver1DOB = value; }
        }

        string _driver1Occupation;
        public string Driver1Occupation
        {
            get { return _driver1Occupation; }
            set { _driver1Occupation = value; }
        }

        string _driver1JobNature;
        public string Driver1JobNature
        {
            get { return _driver1JobNature; }
            set { _driver1JobNature = value; }
        }

        string _driver1MaritalStatus;
        public string Driver1MaritalStatus
        {
            get { return _driver1MaritalStatus; }
            set { _driver1MaritalStatus = value; }
        }

        Int32 _driver1DrivingExperience;
        public Int32 Driver1DrivingExperience
        {
            get { return _driver1DrivingExperience; }
            set { _driver1DrivingExperience = value; }
        }

        string _driver2Name;
        public string Driver2Name
        {
            get { return _driver2Name; }
            set { _driver2Name = value; }
        }

        string _driver2Gender;
        public string Driver2gender
        {
            get { return _driver2Gender; }
            set { _driver2Gender = value; }
        }

        DateTime _driver2DOB;
        public DateTime Driver2DOB
        {
            get { return _driver2DOB; }
            set { _driver2DOB = value; }
        }

        string _driver2Occupation;
        public string Driver2Occupation
        {
            get { return _driver2Occupation; }
            set { _driver2Occupation = value; }
        }

        string _driver2JobNature;
        public string Driver2JobNature
        {
            get { return _driver2JobNature; }
            set { _driver2JobNature = value; }
        }

        string _driver2MaritalStatus;
        public string Driver2MaritalStatus
        {
            get { return _driver2MaritalStatus; }
            set { _driver2MaritalStatus = value; }
        }

        Int32 _driver2DrivingExperience;
        public Int32 Driver2DrivingExperience
        {
            get { return _driver2DrivingExperience; }
            set { _driver2DrivingExperience = value; }
        }

        string _driver3Name;
        public string Driver3Name
        {
            get { return _driver3Name; }
            set { _driver3Name = value; }
        }

        string _driver3Gender;
        public string Driver3gender
        {
            get { return _driver3Gender; }
            set { _driver3Gender = value; }
        }

        DateTime _driver3DOB;
        public DateTime Driver3DOB
        {
            get { return _driver3DOB; }
            set { _driver3DOB = value; }
        }

        string _driver3Occupation;
        public string Driver3Occupation
        {
            get { return _driver3Occupation; }
            set { _driver3Occupation = value; }
        }

        string _driver3JobNature;
        public string Driver3JobNature
        {
            get { return _driver3JobNature; }
            set { _driver3JobNature = value; }
        }

        string _driver3MaritalStatus;
        public string Driver3MaritalStatus
        {
            get { return _driver3MaritalStatus; }
            set { _driver3MaritalStatus = value; }
        }

        Int32 _driver3DrivingExperience;
        public Int32 Driver3DrivingExperience
        {
            get { return _driver3DrivingExperience; }
            set { _driver3DrivingExperience = value; }
        }


        string _driver4Name;
        public string Driver4Name
        {
            get { return _driver4Name; }
            set { _driver4Name = value; }
        }

        string _driver4Gender;
        public string Driver4gender
        {
            get { return _driver4Gender; }
            set { _driver4Gender = value; }
        }

        DateTime _driver4DOB;
        public DateTime Driver4DOB
        {
            get { return _driver4DOB; }
            set { _driver4DOB = value; }
        }

        string _driver4Occupation;
        public string Driver4Occupation
        {
            get { return _driver4Occupation; }
            set { _driver4Occupation = value; }
        }

        string _driver4JobNature;
        public string Driver4JobNature
        {
            get { return _driver4JobNature; }
            set { _driver4JobNature = value; }
        }

        string _driver4MaritalStatus;
        public string Driver4MaritalStatus
        {
            get { return _driver4MaritalStatus; }
            set { _driver4MaritalStatus = value; }
        }

        Int32 _driver4DrivingExperience;
        public Int32 Driver4DrivingExperience
        {
            get { return _driver4DrivingExperience; }
            set { _driver4DrivingExperience = value; }
        }

        string _driver5Name;
        public string Driver5Name
        {
            get { return _driver5Name; }
            set { _driver5Name = value; }
        }

        string _driver5Gender;
        public string Driver5gender
        {
            get { return _driver5Gender; }
            set { _driver5Gender = value; }
        }

        DateTime _driver5DOB;
        public DateTime Driver5DOB
        {
            get { return _driver5DOB; }
            set { _driver5DOB = value; }
        }

        string _driver5Occupation;
        public string Driver5Occupation
        {
            get { return _driver5Occupation; }
            set { _driver5Occupation = value; }
        }

        string _driver5JobNature;
        public string Driver5JobNature
        {
            get { return _driver5JobNature; }
            set { _driver5JobNature = value; }
        }

        string _driver5MaritalStatus;
        public string Driver5MaritalStatus
        {
            get { return _driver5MaritalStatus; }
            set { _driver5MaritalStatus = value; }
        }

        Int32 _driver5DrivingExperience;
        public Int32 Driver5DrivingExperience
        {
            get { return _driver5DrivingExperience; }
            set { _driver5DrivingExperience = value; }
        }



        #endregion

        #region Vehicle Details

        string _vehicleNo;
        public string VehicleNo
        {
            get { return _vehicleNo; }
            set { _vehicleNo = value; }
        }

        string _chassisNo;
        public string ChassisNo
        {
            get { return _chassisNo; }
            set { _chassisNo = value; }
        }

        string _bodyType;
        public string BodyType
        {
            get { return _bodyType; }
            set { _bodyType = value; }
        }

        string _engineNo;
        public string EngineNo
        {
            get { return _engineNo; }
            set { _engineNo = value; }
        }

        string _carMake;
        public string CarMake
        {
            get { return _carMake; }
            set { _carMake = value; }
        }

        string _carModel;
        public string CarModel
        {
            get { return _carModel; }
            set { _carModel = value; }
        }

        Int32 _yearOfManufacture;
        public Int32 YearOfManufacture
        {
            get { return _yearOfManufacture; }
            set { _yearOfManufacture = value; }
        }

        Int32 _yearOfRegistration;
        public Int32 YearOfRegistration
        {
            get { return _yearOfRegistration; }
            set { _yearOfRegistration = value; }
        }


        Int32 _carCC;
        public Int32 CarCC
        {
            get { return _carCC; }
            set { _carCC = value; }
        }

        Int32 _carSeaters;
        public Int32 CarSeaters
        {
            get { return _carSeaters; }
            set { _carSeaters = value; }
        }

        string _odometerReading;
        public string OdometerReading
        {
            get { return _odometerReading; }
            set { _odometerReading = value; }
        }

        string _estimatedMarketValue;
        public string EstimatedMarketValue
        {
            get { return _estimatedMarketValue; }
            set { _estimatedMarketValue = value; }
        }

        #endregion

        #region ClaimDetails

        string _currentInsuranceCo;
        public string CurrentInsuranceCo
        {
            get { return _currentInsuranceCo; }
            set { _currentInsuranceCo = value; }
        }

        string _policyNo;
        public string PolicyNo
        {
            get { return _policyNo; }
            set { _policyNo = value; }
        }

        DateTime _expiryCancellationDate;
        public DateTime ExpiryCancellationDate
        {
            get { return _expiryCancellationDate; }
            set { _expiryCancellationDate = value; }
        }

        string _last3yearsClaimXP;
        public string Last3YearsClaimXP
        {
            get { return _last3yearsClaimXP; }
            set { _last3yearsClaimXP = value; }
        }

        string _noClaimsLast3Years;
        public string NoClaimsLast3Years
        {
            get { return _noClaimsLast3Years; }
            set { _noClaimsLast3Years = value; }
        }

        string _NCDPercent;
        public string NCDPercent
        {
            get { return _NCDPercent; }
            set { _NCDPercent = value; }
        }

        string _OFD;
        public string OFD
        {
            get { return _OFD; }
            set { _OFD = value; }
        }

        //string _AddDiscount;
        //public string AdditionalDiscount
        //{
        //    get { return _AddDiscount; }
        //    set { _AddDiscount = value; }
        //}

        string _NCDProtector;
        public string NCDProtector
        {
            get { return _NCDProtector; }
            set { _NCDProtector = value; }
        }

        string _ncdNilDetails;
        public string NCDNilDetails
        {
            get { return _ncdNilDetails; }
            set { _ncdNilDetails = value; }
        }

        bool _isCarModified;
        public bool IsCarModified
        {
            get { return _isCarModified; }
            set { _isCarModified = value; }
        }

        string _modifiedReason;
        public string ModifiedReason
        {
            get { return _modifiedReason; }
            set { _modifiedReason = value; }
        }


        #endregion

        #region Policy Details

        string _financeCo;
        public string FinanceCo
        {
            get { return _financeCo; }
            set { _financeCo = value; }
        }

        string _usage;
        public string Usage
        {
            get { return _usage; }
            set { _usage = value; }
        }

        string _typeofcover;
        public string TypeOfCover
        {
            get { return _typeofcover; }
            set { _typeofcover = value; }
        }

        DateTime _periodFrom;
        public DateTime PeriodFrom
        {
            get { return _periodFrom; }
            set { _periodFrom = value; }
        }

        DateTime _periodTo;
        public DateTime PeriodTo
        {
            get { return _periodTo; }
            set { _periodTo = value; }
        }

        #endregion

        #region Other Info

        string _driveToWestMalaysia;
        public string DriveToWestMalaysia
        {
            get { return _driveToWestMalaysia; }
            set { _driveToWestMalaysia = value; }
        }

        bool _isConvictedOfMotoringOffense;
        public bool IsConvictedOfMotoringOffense
        {
            get { return _isConvictedOfMotoringOffense; }
            set { _isConvictedOfMotoringOffense = value; }
        }

        string _convictedReason;
        public string ConvictedReason
        {
            get { return _convictedReason; }
            set { _convictedReason = value; }
        }

        bool _isGivenDemeritPoints;
        public bool IsGivenDemeritPoints
        {
            get { return _isGivenDemeritPoints; }
            set { _isGivenDemeritPoints = value; }
        }

        string _demeritPointsReason;
        public string DemeritPointsReason
        {
            get { return _demeritPointsReason; }
            set { _demeritPointsReason = value; }
        }

        bool _isDisabled;
        public bool isDisabled
        {
            get { return _isDisabled; }
            set { _isDisabled = value; }
        }

        string _disablityReason;
        public string DisablityReason
        {
            get { return _disablityReason; }
            set { _disablityReason = value; }
        }

        bool _isRefusedMotorInsurance;
        public bool IsRefusedMotorInsurance
        {
            get { return _isRefusedMotorInsurance; }
            set { _isRefusedMotorInsurance = value; }
        }

        string _refusedReason;
        public string RefusedReason
        {
            get { return _refusedReason; }
            set { _refusedReason = value; }
        }

        bool _isTerminatedDueToPayment;
        public bool IsTerminatedDueToPayment
        {
            get { return _isTerminatedDueToPayment; }
            set { _isTerminatedDueToPayment = value; }
        }

        string _terminatedReason;
        public string TerminatedReason
        {
            get { return _terminatedReason; }
            set { _terminatedReason = value; }
        }



        #endregion

        #region Payment Details

        int _excess;
        public int Excess
        {
            get { return _excess; }
            set { _excess = value; }
        }

        float _totalPremium;
        public float TotalPremium
        {
            get { return _totalPremium; }
            set { _totalPremium = value; }
        }

        float _basicPremium;
        public float BasicPremium
        {
            get { return _basicPremium; }
            set { _basicPremium = value; }
        }

        float _ofdRate;
        public float OFDRate
        {
            get { return _ofdRate; }
            set { _ofdRate = value; }
        }

        //float _addDiscountRate;
        //public float AddDiscountRate
        //{
        //    get { return _addDiscountRate; }
        //    set { _addDiscountRate = value; }
        //}

        float _buyupdownRate;
        public float BuyUpDownRate
        {
            get { return _buyupdownRate; }
            set { _buyupdownRate = value; }
        }

        float _gstRate;
        public float GSTRate
        {
            get { return _gstRate; }
            set { _gstRate = value; }
        }

        float _ncdDiscountRate;
        public float NCDDiscountRate
        {
            get { return _ncdDiscountRate; }
            set { _ncdDiscountRate = value; }
        }

        float _ncdProtectorRate;
        public float NCDProtectorRate
        {
            get { return _ncdProtectorRate; }
            set { _ncdProtectorRate = value; }
        }

        float _grossPremium;
        public float GrossPremium
        {
            get { return _grossPremium; }
            set { _grossPremium = value; }
        }

        float _additionalDriverCharge;
        public float AdditionalDriverCharge
        {
            get { return _additionalDriverCharge; }
            set { _additionalDriverCharge = value; }
        }

        string _cardType;
        public string CardType
        {
            get { return _cardType; }
            set { _cardType = value; }
        }

        string _cardNo;
        public string CardNo
        {
            get { return _cardNo; }
            set { _cardNo = value; }
        }

        DateTime _cardExpiryDate;
        public DateTime CardExpiryDate
        {
            get { return _cardExpiryDate; }
            set { _cardExpiryDate = value; }
        }

        string _cardholdersName;
        public string CardholdersName
        {
            get { return _cardholdersName; }
            set { _cardholdersName = value; }
        }


        #endregion


        public AZCpCarInsurancePDFOutput()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private void DrawBoxWithText(XGraphics _objG, XColor _xcolor, int x, int y, int width, int height, double borderWidth, string strText, string strFontName, double fontSize, XFontStyle xFontStyle)
        {

            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(0, 0, 0, 0);
            _rect.X = x;
            _rect.Y = y;
            _rect.Width = width;
            _rect.Height = height;
            XPen _pen = new XPen(_xcolor);
            _pen.Width = borderWidth;
            XFont font = new XFont(strFontName, fontSize, xFontStyle);
            _objG.DrawRectangle(_pen, _rect);
            _objG.DrawString(strText, font, XBrushes.Black, _rect, XStringFormats.Center);
        }

        private void DrawBoxWithTextList(XGraphics _objG, XColor _xcolor, int x, int y, int width, int height, int rows, int cols, double borderWidth, string strFontName, double fontSize, XFontStyle xFontStyle, string[,] _arrData, int[] _arrColsWidth)
        {

            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(0, 0, 0, 0);
            _rect.X = x;
            _rect.Y = y;
            _rect.Width = width;
            _rect.Height = (height + 8) * rows;

            XColor _xOuterBoxColor = new XColor();
            _xOuterBoxColor.R = 0;
            _xOuterBoxColor.G = 0;
            _xOuterBoxColor.B = 0;

            XPen _pen = new XPen(_xcolor);
            _pen.Width = borderWidth;
            XFont font = new XFont(strFontName, fontSize, xFontStyle);
            XFont boldFont = new XFont(strFontName, fontSize, XFontStyle.Bold);
            _objG.DrawRectangle(_pen, _rect);

            System.Drawing.Rectangle _rectText = new System.Drawing.Rectangle(0, 0, 0, 0);
            _rectText.X = x + 5;
            _rectText.Y = y + 5;
            _rectText.Width = width;
            _rectText.Height = height;

            for (int i = 0; i < rows; i++)
            {
                // Draw the text
                for (int j = 0; j < cols; j++)
                {
                    _rectText.Width = _arrColsWidth[j];
                    if (j == 0)
                    {
                        _objG.DrawString(_arrData[i, j].ToString(), boldFont, XBrushes.Black, _rectText, XStringFormats.TopLeft);
                    }
                    else
                    {
                        _objG.DrawString(_arrData[i, j].ToString(), font, XBrushes.Black, _rectText, XStringFormats.TopLeft);
                    }
                    _rectText.X += _arrColsWidth[j];
                }
                _rectText.X = x + 5;
                _rectText.Y += height + 5;
            }

        }

        private void DrawTable(XGraphics _objG, int x, int y, int rows, int cols, int rowHeight, int[] _arrColsWidth, string[] _arrHeader, string[,] _arrData)
        {
            XColor _xcolor = new XColor();
            _xcolor.R = 0;
            _xcolor.G = 0;
            _xcolor.B = 0;
            System.Drawing.Rectangle _rect = new System.Drawing.Rectangle(0, 0, 0, 0);
            _rect.X = x;
            _rect.Y = y;
            _rect.Width = _arrColsWidth[0];
            _rect.Height = rowHeight;
            XPen _pen = new XPen(_xcolor);
            _pen.Width = 0.5d;
            XFont font = new XFont("Verdana", 5, XFontStyle.Regular);

            for (int h = 0; h < cols; h++)
            {
                _rect.Width = _arrColsWidth[h];
                _objG.DrawRectangle(_pen, _rect);
                _objG.DrawString(_arrHeader[h].ToString(), font, XBrushes.Black,
          new XRect(_rect.X + 3, _rect.Y + 3, 10, 10),
          XStringFormats.TopLeft);
                _rect.X += _arrColsWidth[h];
            }

            _rect.Y += rowHeight;
            _rect.X = x;

            for (int i = 0; i < rows; i++)
            {
                // Draw the text
                for (int j = 0; j < cols; j++)
                {
                    _rect.Width = _arrColsWidth[j];

                    _objG.DrawRectangle(_pen, _rect);
                    _objG.DrawString(_arrData[i, j].ToString(), font, XBrushes.Black,
              new XRect(_rect.X + 3, _rect.Y + 3, 10, 10),
              XStringFormats.TopLeft);
                    _rect.X += _arrColsWidth[j];
                }
                _rect.Y += rowHeight;
                _rect.X = x;
            }
        }

        public string AZCpPDFProposalForm(string strfilename,int userType)
        {   //userType
            // 1 = Provider
            // 0 = Client/Applicant
            string inputfile = CE.Configuration.MyConfigurationManager.GetAppSettingValue("TH.FileOutputPath").ToString();
            inputfile += "pdfoutput\\AZCp\\AZCp.pdf";
            

            // Open the input files
            PdfDocument inputDocument = PdfReader.Open(inputfile, PdfDocumentOpenMode.Import);

            PdfDocument outputDocument = new PdfDocument();
            PdfSecuritySettings securitySettings = outputDocument.SecuritySettings;
            // Setting one of the passwords automatically sets the security level to 
            // PdfDocumentSecurityLevel.Encrypted128Bit.
            //securitySettings.UserPassword = "user";
            //securitySettings.OwnerPassword = "owner";

            //securitySettings.PermitAccessibilityExtractContent = false;
            //securitySettings.PermitAnnotations = false;
            //securitySettings.PermitAssembleDocument = false;
            //securitySettings.PermitExtractContent = false;
            //securitySettings.PermitFormsFill = true;
            //securitySettings.PermitFullQualityPrint = false;
            //securitySettings.PermitModifyDocument = false;
            //securitySettings.PermitPrint = false;

            outputDocument.Info.Title = _pageTitle;

            // Show consecutive pages facing. Requires Acrobat 5 or higher.
            //outputDocument.PageLayout = PdfPageLayout.TwoColumnLeft;
            outputDocument.PageLayout = PdfPageLayout.SinglePage;
            String str = string.Empty;
            XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
            // Create a font
            XFont font = new XFont("Tahoma", 9, XFontStyle.Regular, options);
            XFont fontNormal = new XFont("Tahoma", 7.5, XFontStyle.Regular, options);
            XFont fontMedium = new XFont("Tahoma", 7, XFontStyle.Regular, options);
            XFont fontSmall = new XFont("Tahoma", 6, XFontStyle.Regular, options);
            XFont fontBold = new XFont("Tahoma", 8, XFontStyle.Bold, options);
            XFont fontMediumBold = new XFont("Tahoma", 7, XFontStyle.Bold, options);
            XFont fontSmallBold = new XFont("Tahoma", 6, XFontStyle.Bold, options);
            //XStringFormat format = new XStringFormat();
            //format.Alignment = XStringAlignment.Center;
            //format.LineAlignment = XLineAlignment.Far;
                      
            int curX = 30;
            int curY = 30;
            
            PdfPage outputpage = outputDocument.AddPage(inputDocument.Pages[0]);

            XGraphics gfx = XGraphics.FromPdfPage(outputpage);

            str = "CX-123"; //_pageTitle;
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 90, curY + 60, 100, 20), XStringFormat.TopLeft);
            str = "CX";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 340, curY + 60, 100, 20), XStringFormat.TopLeft);
            str = "CompareXpress";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 440, curY + 60, 100, 20), XStringFormat.TopLeft);

            str = "X";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 40, curY + 85, 100, 20), XStringFormat.TopLeft);
            str = "AZCp";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 380, curY + 88, 100, 20), XStringFormat.TopLeft);

            str = "โสภณ วรสิทธิ์ชัย";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 120, curY + 108, 100, 20), XStringFormat.TopLeft);
            str = "Tana วรสิทธิ์ชัย";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 120, curY + 125, 100, 20), XStringFormat.TopLeft);

            str = "413 address";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 65, curY + 142, 100, 20), XStringFormat.TopLeft);
            str = "moo";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 190, curY + 142, 100, 20), XStringFormat.TopLeft);
            str = "building";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 300, curY + 142, 100, 20), XStringFormat.TopLeft);
            str = "soi";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 430, curY + 142, 100, 20), XStringFormat.TopLeft);
            
            str = "ถนน";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 65, curY + 160, 100, 20), XStringFormat.TopLeft);
            str = "ตำบล";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 230, curY + 160, 100, 20), XStringFormat.TopLeft);
            str = "อำเภอ";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 400, curY + 160, 100, 20), XStringFormat.TopLeft);

            str = "จังหวัด";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 65, curY + 180, 100, 20), XStringFormat.TopLeft);
            str = "รหัสไปรษณีย์";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 230, curY + 180, 100, 20), XStringFormat.TopLeft);
            str = "โทรศัพท์ home";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 330, curY + 180, 100, 20), XStringFormat.TopLeft);
            str = "โทรศัพท์ office";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 440, curY + 180, 100, 20), XStringFormat.TopLeft);

            str = "X";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 99, curY + 199, 100, 20), XStringFormat.TopLeft);
            str = "ผู้รับผลประโยชน์";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 230, curY + 195, 100, 20), XStringFormat.TopLeft);

            str = DateTime.Today.ToString();
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 180, curY + 215, 100, 20), XStringFormat.TopLeft);
            str = DateTime.Today.ToString();
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 350, curY + 215, 100, 20), XStringFormat.TopLeft);
            
            str = "X";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 95, curY + 260, 100, 20), XStringFormat.TopLeft);
            
            str = "code";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 80, curY + 275, 100, 20), XStringFormat.TopLeft);
            str = "ยี่ห้อ";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 200, curY + 275, 100, 20), XStringFormat.TopLeft);
            str = "version";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 300, curY + 275, 100, 20), XStringFormat.TopLeft);
            str = "Year";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 430, curY + 275, 100, 20), XStringFormat.TopLeft);

            str = "cc";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 100, curY + 290, 100, 20), XStringFormat.TopLeft);
            str = "kg";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 220, curY + 290, 100, 20), XStringFormat.TopLeft);
            str = "seat";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 340, curY + 290, 100, 20), XStringFormat.TopLeft);
            str = "color";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 430, curY + 290, 100, 20), XStringFormat.TopLeft);

            str = "motor";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 100, curY + 310, 100, 20), XStringFormat.TopLeft);
            str = "Chassis";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 320, curY + 310, 100, 20), XStringFormat.TopLeft);
            
            str = "เลขทะเบียน";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 100, curY + 325, 100, 20), XStringFormat.TopLeft);
            str = "Chassis";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 320, curY + 325, 100, 20), XStringFormat.TopLeft);
            str = "Sum Insured";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 140, curY + 345, 100, 20), XStringFormat.TopLeft);
            str = "Sum Insured";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 140, curY + 362, 100, 20), XStringFormat.TopLeft);
            str = "Sum Insured";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 140, curY + 380, 100, 20), XStringFormat.TopLeft);

            str = "X";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 430, curY + 405, 100, 20), XStringFormat.TopLeft);
            str = "X.";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 40, curY + 423, 100, 20), XStringFormat.TopLeft);
            str = "X..";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 165, curY + 425, 100, 20), XStringFormat.TopLeft);

            str = "Name Surname";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 360, curY + 420, 100, 20), XStringFormat.TopLeft);
            str = "DOB Date";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 360, curY + 438, 100, 20), XStringFormat.TopLeft);
            str = "Driver License";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 360, curY + 456, 100, 20), XStringFormat.TopLeft);

            str = "Name Surname";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 360, curY + 475, 100, 20), XStringFormat.TopLeft);
            str = "DOB Date";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 360, curY + 490, 100, 20), XStringFormat.TopLeft);
            str = "Driver License";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 360, curY + 510, 100, 20), XStringFormat.TopLeft);


            str = "SumInsured 100";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 120, curY + 530, 100, 20), XStringFormat.TopLeft);
            str = "sum CMI";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 280, curY + 530, 100, 20), XStringFormat.TopLeft);
            str = "Total vol 100";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 430, curY + 530, 100, 20), XStringFormat.TopLeft);
            
            str = "name";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 140, curY + 687, 100, 20), XStringFormat.TopLeft);
            str = "date";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 320, curY + 687, 100, 20), XStringFormat.TopLeft);
            str = "time";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 430, curY + 687, 100, 20), XStringFormat.TopLeft);

            str = "name 2";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 140, curY + 705, 100, 20), XStringFormat.TopLeft);
            str = "date 2";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 320, curY + 705, 100, 20), XStringFormat.TopLeft);
            str = "time 2";
            gfx.DrawString(str, font, XBrushes.DarkBlue, new XRect(curX + 430, curY + 705, 100, 20), XStringFormat.TopLeft);

            // Save the document...
            //string filename = "CompareDocument1.pdf";
            string _filePath = GetFilePathAZCp();
            string filename = _filePath + strfilename + ".pdf";

            outputDocument.Save(filename);
            // ...and start a viewer.
            //Process.Start(filename);
            return filename;
        }



        private string isTrue(string ibool)
        {
            string retval = "Yes";

            if (ibool == "False")
                retval = "No";

            return retval;
        }


        public void ClearFields()
        {
            _proposalNo = "";
            _pageTitle = "Motor Insurance Proposal";

            _revisionNo = "";
            _quotationNo = "";
            _producerCode = "";
            _Applicationdate = DateTime.Now;

            #region Customer Profile
            _customerName = "";
            _customerAddress = "";
            _customerUnitNo = "";
            _customerHomeNo = "";
            _customerPostCode = "";
            _NRIC = "";
            _officemobileNo = "";
            _employersName = "";
            _emailaddress = "";
            _customerGender = "";
            _customerDOB = DateTime.Now;
            _customeroccupation = "";
            _customerjobnature = "";
            _customermaritalstatus = "";
            _customerdrivingexperience = 4;

            #endregion

            #region Addtnal Drivers

            _driver1Name = "John Tn";
            _driver1Gender = "";
            _driver1DOB = DateTime.Now;
            _driver1Occupation = "";
            _driver1JobNature = "";
            _driver1MaritalStatus = "";
            _driver1DrivingExperience = 0;

            _driver2Name = "";
            _driver2Gender = "";
            _driver2DOB = DateTime.Now;
            _driver2Occupation = "";
            _driver2JobNature = "";
            _driver2MaritalStatus = "";
            _driver2DrivingExperience = 0;

            _driver3Name = "";
            _driver3Gender = "";
            _driver3DOB = DateTime.Now;
            _driver3Occupation = "";
            _driver3JobNature = "";
            _driver3MaritalStatus = "";
            _driver3DrivingExperience = 0;

            _driver4Name = "";
            _driver4Gender = "";
            _driver4DOB = DateTime.Now;
            _driver4Occupation = "";
            _driver4JobNature = "";
            _driver4MaritalStatus = "";
            _driver4DrivingExperience = 0;

            _driver5Name = "";
            _driver5Gender = "";
            _driver5DOB = DateTime.Now;
            _driver5Occupation = "";
            _driver5JobNature = "";
            _driver5MaritalStatus = "";
            _driver5DrivingExperience = 0;

            #endregion

            #region Vehicle Details

            _vehicleNo = ""; // "S59D112233";
            _chassisNo = ""; // "S59D112233";
            _bodyType = ""; //"Saloon";
            _engineNo = ""; // "S59D112233";
            _carMake = ""; // "Toyota";
            _carModel = ""; // "Altis";
            _yearOfManufacture = 0; // 2008;
            _yearOfRegistration = 0; // 2008;
            _carCC = 0; // 1498;
            _carSeaters = 0;
            _odometerReading = "";
            _estimatedMarketValue = "";

            #endregion

            #region ClaimDetails

            _currentInsuranceCo = ""; // "AIG";
            _policyNo = "";
            _expiryCancellationDate = DateTime.Now;
            _last3yearsClaimXP = "None";
            _noClaimsLast3Years = "0";
            _NCDPercent = "0";
            _OFD = "Yes";
            _NCDProtector = "No";
            _ncdNilDetails = "Not Applicable";

            _isCarModified = false;
            _modifiedReason = "";

            #endregion

            #region Policy Details

            _financeCo = ""; // "DBS BANK LTD";
            _usage = ""; // "Private Use";
            _typeofcover = ""; // "Comprehensive - Private Car-Preferred Plan";
            _periodFrom = DateTime.Now;
            _periodTo = DateTime.Now;

            #endregion

            #region Other Info

            _driveToWestMalaysia = "Monthly";
            _isConvictedOfMotoringOffense = false;
            _convictedReason = "";

            _isGivenDemeritPoints = false;
            _demeritPointsReason = "";

            _isDisabled = false;
            _disablityReason = "";

            _isRefusedMotorInsurance = false;
            _refusedReason = "";

            _isTerminatedDueToPayment = false;
            _terminatedReason = "";


            #endregion

            #region Payment Details

            _excess = 0;
            _totalPremium = 0;
            _basicPremium = 0;
            _ofdRate = 0;
            _buyupdownRate = 0;
            _gstRate = 0;
            _ncdDiscountRate = 0;
            _ncdProtectorRate = 0;
            _grossPremium = 0;
            _additionalDriverCharge = 0;
            
            
            _cardType = ""; // "Master";
            _cardNo = ""; // "1111 2222 3333 XXXX";
            _cardExpiryDate = DateTime.Now;
            _cardholdersName = ""; // "JAMES TESTER";

            #endregion

        }

        public string GetFilePathAZCp()
        {
            string _filePath = CE.Configuration.MyConfigurationManager.GetAppSettingValue("TH.FileOutputPath").ToString();
            _filePath += "pdfoutput\\AZCp\\";
            CE.InputOut.MyIO _myIO = new CE.InputOut.MyIO();
            string _todaydate = DateTime.Now.ToString("yyyyMMMdd");
            if (!_myIO.CheckDirectory(_filePath + _todaydate))
            {
                if (_myIO.CreateDirectory(_filePath, _todaydate))
                {
                    _filePath += _todaydate + "\\";
                }
            }
            else
            {
                _filePath += _todaydate + "\\";
            }

            return _filePath;
        }

    }
}
